{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sqlalchemy import create_engine\n",
    "\n",
    "sqlpath = 'sqlite:///db.sql'\n",
    "engine = create_engine(sqlpath, echo=True)\n",
    "from sqlalchemy.ext.declarative import declarative_base\n",
    "Base = declarative_base()\n",
    "\n",
    "from sqlalchemy import Column, Integer, String\n",
    "class Post(Base):\n",
    "    __tablename__ = 'posts'\n",
    "    id = Column(Integer, primary_key=True)\n",
    "    topic_content = Column(String)\n",
    "    post_content = Column(String)\n",
    "    post_authar = Column(String)\n",
    "    url = Column(String)\n",
    "    def __repr__(self):\n",
    "        return \"<Post(topic_content='%s', post_content='%s', post_authar='%s', url='%s')>\" % (self.topic_content, self.post_content, self.post_authar, self.url)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2017-11-25 17:38:04,815 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1\n",
      "2017-11-25 17:38:04,817 INFO sqlalchemy.engine.base.Engine ()\n",
      "2017-11-25 17:38:04,819 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1\n",
      "2017-11-25 17:38:04,820 INFO sqlalchemy.engine.base.Engine ()\n",
      "2017-11-25 17:38:04,822 INFO sqlalchemy.engine.base.Engine PRAGMA table_info(\"posts\")\n",
      "2017-11-25 17:38:04,823 INFO sqlalchemy.engine.base.Engine ()\n"
     ]
    }
   ],
   "source": [
    "Base.metadata.create_all(engine)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2017-11-25 17:38:10,751 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)\n",
      "2017-11-25 17:38:10,753 INFO sqlalchemy.engine.base.Engine SELECT posts.id AS posts_id, posts.topic_content AS posts_topic_content, posts.post_content AS posts_post_content, posts.post_authar AS posts_post_authar, posts.url AS posts_url \n",
      "FROM posts ORDER BY posts.id\n",
      "2017-11-25 17:38:10,754 INFO sqlalchemy.engine.base.Engine ()\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. bitcoin and paypal   send me the info of the hack to my email @ darkelite187@secmail.pro\n",
      "3. darkelite187\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. Hello mr.dark I am new here in your site just wondering how I can dowload these zip files in your brotherhood forum?I want to learn about hacking.Thanks in advance.\n",
      "3. JuzWannaPlay\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. How do I stop my real name appearing on any financial transactions?\n",
      "3. binky1902\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. How do I use bitcoin, because my bank need to confirm the payment by telephone and I don't want that to happen?\n",
      "3. binky1902\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. i be setting up paypal soon can u email me me with the info @ darkelite187@secmail.pro thanks\n",
      "3. darkelite187\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. oh btw download the new tool i posted up last night\n",
      "3. darkelite187\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. i have debit card details with owners name, the first five and last four digits, expiration date  if you have any means by which we can use the to make money  let's discuss about it\n",
      "3. khan\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. buy bitcoins with it lol\n",
      "3. darkelite187\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. come on I also got means to pos data on sales too\n",
      "3. khan\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n"
     ]
    }
   ],
   "source": [
    "from sqlalchemy.orm import sessionmaker\n",
    "Session = sessionmaker(bind=engine)\n",
    "session = Session()\n",
    "for instance in session.query(Post).order_by(Post.id):\n",
    "    print '------------------------------'\n",
    "    print '1. ' + instance.topic_content\n",
    "    print '2. ' + instance.post_content\n",
    "    print '3. ' + instance.post_authar\n",
    "    print '4. ' + instance.url"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting mysql-python\n",
      "  Downloading MySQL-python-1.2.5.zip (108kB)\n",
      "\u001b[K    100% |████████████████████████████████| 112kB 52kB/s ta 0:00:01\n",
      "\u001b[?25h    Complete output from command python setup.py egg_info:\n",
      "    sh: mysql_config: command not found\n",
      "    Traceback (most recent call last):\n",
      "      File \"<string>\", line 1, in <module>\n",
      "      File \"/private/var/folders/8q/km15l9rn42vd5zt30hw0srnw0000gy/T/pip-build-JMTF2E/mysql-python/setup.py\", line 17, in <module>\n",
      "        metadata, options = get_config()\n",
      "      File \"setup_posix.py\", line 43, in get_config\n",
      "        libs = mysql_config(\"libs_r\")\n",
      "      File \"setup_posix.py\", line 25, in mysql_config\n",
      "        raise EnvironmentError(\"%s not found\" % (mysql_config.path,))\n",
      "    EnvironmentError: mysql_config not found\n",
      "    \n",
      "    ----------------------------------------\n",
      "\u001b[31mCommand \"python setup.py egg_info\" failed with error code 1 in /private/var/folders/8q/km15l9rn42vd5zt30hw0srnw0000gy/T/pip-build-JMTF2E/mysql-python/\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip install mysql-python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
